<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>GIOScheduler</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="index.html" title="GIO Reference Manual">
<link rel="up" href="async.html" title="Asynchronous I/O">
<link rel="prev" href="GAsyncResult.html" title="GAsyncResult">
<link rel="next" href="GSimpleAsyncResult.html" title="GSimpleAsyncResult">
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="part" href="pt01.html" title="Part&#160;I.&#160;GIO Overview">
<link rel="chapter" href="ch01.html" title="Introduction">
<link rel="chapter" href="ch02.html" title="Compiling GIO applications">
<link rel="chapter" href="ch03.html" title="Running GIO applications">
<link rel="chapter" href="gio-extension-points.html" title="Extending GIO">
<link rel="part" href="pt02.html" title="Part&#160;II.&#160;API Reference">
<link rel="chapter" href="file_ops.html" title="File Operations">
<link rel="chapter" href="file_mon.html" title="File System Monitoring">
<link rel="chapter" href="async.html" title="Asynchronous I/O">
<link rel="chapter" href="streaming.html" title="Streaming I/O">
<link rel="chapter" href="types.html" title="File types and applications">
<link rel="chapter" href="volume_mon.html" title="Volumes and Drives">
<link rel="chapter" href="icons.html" title="Icons">
<link rel="chapter" href="utils.html" title="Utilities">
<link rel="chapter" href="extending.html" title="Extending GIO">
<link rel="part" href="migrating.html" title="Part&#160;III.&#160;Migrating to GIO">
<link rel="chapter" href="ch14.html" title="Migrating from POSIX to GIO">
<link rel="chapter" href="ch15.html" title="Migrating from GnomeVFS to GIO">
<link rel="chapter" href="gio-hierarchy.html" title="Object Hierarchy">
<link rel="index" href="ix01.html" title="Index">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="GAsyncResult.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="async.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GIO Reference Manual</th>
<td><a accesskey="n" href="GSimpleAsyncResult.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2785534" class="shortcut">Top</a>
                  &#160;|&#160;
                  <a href="#id2750728" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="gio-GIOScheduler"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id2785534"></a><span class="refentrytitle">GIOScheduler</span>
</h2>
<p>GIOScheduler &#8212; I/O Scheduler</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">

#include &lt;gio/gio.h&gt;


                    <a class="link" href="gio-GIOScheduler.html#GIOSchedulerJob">GIOSchedulerJob</a>;
<a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
>gboolean</a>            (<a class="link" href="gio-GIOScheduler.html#GIOSchedulerJobFunc">*GIOSchedulerJobFunc</a>)              (<a class="link" href="gio-GIOScheduler.html#GIOSchedulerJob">GIOSchedulerJob</a> *job,
                                                         <a class="link" href="GCancellable.html" title="GCancellable">GCancellable</a> *cancellable,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> user_data);
void                <a class="link" href="gio-GIOScheduler.html#g-io-scheduler-push-job">g_io_scheduler_push_job</a>             (<a class="link" href="gio-GIOScheduler.html#GIOSchedulerJobFunc">GIOSchedulerJobFunc</a> job_func,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> user_data,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Datasets.html#GDestroyNotify"
>GDestroyNotify</a> notify,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"
>gint</a> io_priority,
                                                         <a class="link" href="GCancellable.html" title="GCancellable">GCancellable</a> *cancellable);
void                <a class="link" href="gio-GIOScheduler.html#g-io-scheduler-cancel-all-jobs">g_io_scheduler_cancel_all_jobs</a>      (void);
<a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
>gboolean</a>            <a class="link" href="gio-GIOScheduler.html#g-io-scheduler-job-send-to-mainloop">g_io_scheduler_job_send_to_mainloop</a> (<a class="link" href="gio-GIOScheduler.html#GIOSchedulerJob">GIOSchedulerJob</a> *job,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"
>GSourceFunc</a> func,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> user_data,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Datasets.html#GDestroyNotify"
>GDestroyNotify</a> notify);
void                <a class="link" href="gio-GIOScheduler.html#g-io-scheduler-job-send-to-mainloop-async">g_io_scheduler_job_send_to_mainloop_async</a>
                                                        (<a class="link" href="gio-GIOScheduler.html#GIOSchedulerJob">GIOSchedulerJob</a> *job,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"
>GSourceFunc</a> func,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> user_data,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Datasets.html#GDestroyNotify"
>GDestroyNotify</a> notify);
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id2750728"></a><h2>Description</h2>
<p>
Schedules asynchronous I/O operations. <span class="type">GIOScheduler</span> integrates 
into the main event loop (<a
href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GMainLoop"
><span class="type">GMainLoop</span></a>) and may use threads if they 
are available.
</p>
<p>
</p>
<p><a name="io-priority"></a><a class="indexterm" name="id2750764"></a>
Each I/O operation has a priority, and the scheduler uses the priorities
to determine the order in which operations are executed. They are 
<span class="emphasis"><em>not</em></span> used to determine system-wide I/O scheduling.
Priorities are integers, with lower numbers indicating higher priority. 
It is recommended to choose priorities between <a
href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#G-PRIORITY-LOW:CAPS"
><code class="literal">G_PRIORITY_LOW</code></a> and 
<a
href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH:CAPS"
><code class="literal">G_PRIORITY_HIGH</code></a>, with <a
href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS"
><code class="literal">G_PRIORITY_DEFAULT</code></a> as a default.
</p>
<p>

</p>
</div>
<div class="refsect1" lang="en">
<a name="id2750814"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id2750824"></a><h3>
<a name="GIOSchedulerJob"></a>GIOSchedulerJob</h3>
<a class="indexterm" name="id2750837"></a><pre class="programlisting">typedef struct _GIOSchedulerJob GIOSchedulerJob;</pre>
<p>
Opaque class for definining and scheduling IO jobs.</p>
<p>

</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2750858"></a><h3>
<a name="GIOSchedulerJobFunc"></a>GIOSchedulerJobFunc ()</h3>
<a class="indexterm" name="id2750870"></a><pre class="programlisting"><a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
>gboolean</a>            (*GIOSchedulerJobFunc)              (<a class="link" href="gio-GIOScheduler.html#GIOSchedulerJob">GIOSchedulerJob</a> *job,
                                                         <a class="link" href="GCancellable.html" title="GCancellable">GCancellable</a> *cancellable,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> user_data);</pre>
<p>
I/O Job function. 
</p>
<p>
Note that depending on whether threads are available, the 
<span class="type">GIOScheduler</span> may run jobs in separate threads or in an idle 
in the mainloop. 
</p>
<p>
Long-running jobs should periodically check the <em class="parameter"><code>cancellable</code></em>
to see if they have been cancelled.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>job</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="gio-GIOScheduler.html#GIOSchedulerJob"><span class="type">GIOSchedulerJob</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cancellable</code></em>&#160;:</span></p></td>
<td> optional <a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> object, <a
href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"
><code class="literal">NULL</code></a> to ignore.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</span></p></td>
<td> the data to pass to callback function
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> <a
href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"
><code class="literal">TRUE</code></a> if this function should be called again to
   complete the job, <a
href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"
><code class="literal">FALSE</code></a> if the job is complete (or cancelled)
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2800255"></a><h3>
<a name="g-io-scheduler-push-job"></a>g_io_scheduler_push_job ()</h3>
<a class="indexterm" name="id2800267"></a><pre class="programlisting">void                g_io_scheduler_push_job             (<a class="link" href="gio-GIOScheduler.html#GIOSchedulerJobFunc">GIOSchedulerJobFunc</a> job_func,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> user_data,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Datasets.html#GDestroyNotify"
>GDestroyNotify</a> notify,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"
>gint</a> io_priority,
                                                         <a class="link" href="GCancellable.html" title="GCancellable">GCancellable</a> *cancellable);</pre>
<p>
Schedules the I/O job to run. 
</p>
<p>
<em class="parameter"><code>notify</code></em> will be called on <em class="parameter"><code>user_data</code></em> after <em class="parameter"><code>job_func</code></em> has returned,
regardless whether the job was cancelled or has run to completion.
</p>
<p>
If <em class="parameter"><code>cancellable</code></em> is not <a
href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"
><code class="literal">NULL</code></a>, it can be used to cancel the I/O job
by calling <a class="link" href="GCancellable.html#g-cancellable-cancel"><code class="function">g_cancellable_cancel()</code></a> or by calling 
<a class="link" href="gio-GIOScheduler.html#g-io-scheduler-cancel-all-jobs"><code class="function">g_io_scheduler_cancel_all_jobs()</code></a>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>job_func</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="gio-GIOScheduler.html#GIOSchedulerJobFunc"><span class="type">GIOSchedulerJobFunc</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</span></p></td>
<td> data to pass to <em class="parameter"><code>job_func</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>notify</code></em>&#160;:</span></p></td>
<td> a <a
href="/usr/share/gtk-doc/html/glib/glib-Datasets.html#GDestroyNotify"
><span class="type">GDestroyNotify</span></a> for <em class="parameter"><code>user_data</code></em>, or <a
href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"
><code class="literal">NULL</code></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>io_priority</code></em>&#160;:</span></p></td>
<td> the I/O priority 
of the request.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cancellable</code></em>&#160;:</span></p></td>
<td> optional <a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> object, <a
href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"
><code class="literal">NULL</code></a> to ignore.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2800522"></a><h3>
<a name="g-io-scheduler-cancel-all-jobs"></a>g_io_scheduler_cancel_all_jobs ()</h3>
<a class="indexterm" name="id2800533"></a><pre class="programlisting">void                g_io_scheduler_cancel_all_jobs      (void);</pre>
<p>
Cancels all cancellable I/O jobs. 
</p>
<p>
A job is cancellable if a <a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> was passed into
<a class="link" href="gio-GIOScheduler.html#g-io-scheduler-push-job"><code class="function">g_io_scheduler_push_job()</code></a>.</p>
<p>

</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2800577"></a><h3>
<a name="g-io-scheduler-job-send-to-mainloop"></a>g_io_scheduler_job_send_to_mainloop ()</h3>
<a class="indexterm" name="id2748793"></a><pre class="programlisting"><a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
>gboolean</a>            g_io_scheduler_job_send_to_mainloop (<a class="link" href="gio-GIOScheduler.html#GIOSchedulerJob">GIOSchedulerJob</a> *job,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"
>GSourceFunc</a> func,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> user_data,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Datasets.html#GDestroyNotify"
>GDestroyNotify</a> notify);</pre>
<p>
Used from an I/O job to send a callback to be run in the 
main loop (main thread), waiting for the result (and thus 
blocking the I/O job).</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>job</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="gio-GIOScheduler.html#GIOSchedulerJob"><span class="type">GIOSchedulerJob</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>func</code></em>&#160;:</span></p></td>
<td> a <a
href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"
><span class="type">GSourceFunc</span></a> callback that will be called in the main thread
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</span></p></td>
<td> data to pass to <em class="parameter"><code>func</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>notify</code></em>&#160;:</span></p></td>
<td> a <a
href="/usr/share/gtk-doc/html/glib/glib-Datasets.html#GDestroyNotify"
><span class="type">GDestroyNotify</span></a> for <em class="parameter"><code>user_data</code></em>, or <a
href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"
><code class="literal">NULL</code></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> The return value of <em class="parameter"><code>func</code></em>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2748970"></a><h3>
<a name="g-io-scheduler-job-send-to-mainloop-async"></a>g_io_scheduler_job_send_to_mainloop_async ()</h3>
<a class="indexterm" name="id2748982"></a><pre class="programlisting">void                g_io_scheduler_job_send_to_mainloop_async
                                                        (<a class="link" href="gio-GIOScheduler.html#GIOSchedulerJob">GIOSchedulerJob</a> *job,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"
>GSourceFunc</a> func,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> user_data,
                                                         <a
href="/usr/share/gtk-doc/html/glib/glib-Datasets.html#GDestroyNotify"
>GDestroyNotify</a> notify);</pre>
<p>
Used from an I/O job to send a callback to be run asynchronously 
in the main loop (main thread). The callback will be run when the 
main loop is available, but at that time the I/O job might have 
finished. The return value from the callback is ignored.
</p>
<p>
Note that if you are passing the <em class="parameter"><code>user_data</code></em> from <a class="link" href="gio-GIOScheduler.html#g-io-scheduler-push-job"><code class="function">g_io_scheduler_push_job()</code></a>
on to this function you have to ensure that it is not freed before
<em class="parameter"><code>func</code></em> is called, either by passing <a
href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"
><code class="literal">NULL</code></a> as <em class="parameter"><code>notify</code></em> to 
<a class="link" href="gio-GIOScheduler.html#g-io-scheduler-push-job"><code class="function">g_io_scheduler_push_job()</code></a> or by using refcounting for <em class="parameter"><code>user_data</code></em>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>job</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="gio-GIOScheduler.html#GIOSchedulerJob"><span class="type">GIOSchedulerJob</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>func</code></em>&#160;:</span></p></td>
<td> a <a
href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"
><span class="type">GSourceFunc</span></a> callback that will be called in the main thread
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</span></p></td>
<td> data to pass to <em class="parameter"><code>func</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>notify</code></em>&#160;:</span></p></td>
<td> a <a
href="/usr/share/gtk-doc/html/glib/glib-Datasets.html#GDestroyNotify"
><span class="type">GDestroyNotify</span></a> for <em class="parameter"><code>user_data</code></em>, or <a
href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"
><code class="literal">NULL</code></a>
</td>
</tr>
</tbody>
</table></div>
</div>
</div>
<div class="refsect1" lang="en">
<a name="id2749201"></a><div class="refsect2" lang="en"><a name="id2749202"></a></div>
<hr>
<div class="refsect2" lang="en"><a name="id2749203"></a></div>
</div>
</div>
</body>
</html>
